package bidgetserver;

import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;

import javax.jdo.PersistenceManager;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import emailModule.emailSender;

public class DeleteSearchReminder extends HttpServlet {
	private static final Logger log = Logger.getLogger(DeleteSearchReminder.class.getName());

	public void doPost(HttpServletRequest req, HttpServletResponse resp)
	throws IOException {

		String searchString = req.getParameter("SearchString");
		String userName = req.getParameter("UserName");

		PersistenceManager pm = PMF.get().getPersistenceManager();

		String query = "select from "+Reminder.class.getName()+" where userName == '"+userName+"'";
		query+=" && searchString == '"+searchString+"'";

		List<Reminder> reminderToDel = (List<Reminder>) pm.newQuery(query).execute();
		
		try{
			pm.deletePersistent(reminderToDel.get(0));
			//emailSender.SendEmail("dephrath@gmail.com","delete successful", "from server");
		}
		finally{
			pm.close();
		}





	}
}
